package com.d.business.service.impl;

import com.d.business.dao.BDingTalkDao;
import com.d.business.domain.BDingTalkDO;
import com.d.business.domain.dto.BDingTalkDTO;
import com.d.business.service.BDingTalkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;


@Service
public class BDingTalkServiceImpl implements BDingTalkService {
    @Autowired
    private BDingTalkDao bDingTalkDao;

    @Override
    public BDingTalkDO get(Integer id) {
        return bDingTalkDao.get(id);
    }

    @Override
    public List<BDingTalkDO> list(Map<String, Object> map) {
        return bDingTalkDao.list(map);
    }

    @Override
    public int count(Map<String, Object> map) {
        return bDingTalkDao.count(map);
    }

    @Override
    public int save(BDingTalkDO bDingTalk) {
        return bDingTalkDao.save(bDingTalk);
    }

    @Override
    public int update(BDingTalkDO bDingTalk) {
        return bDingTalkDao.update(bDingTalk);
    }

    @Override
    public int remove(Integer id) {
        return bDingTalkDao.remove(id);
    }

    @Override
    public int updateDingTalkStatus(Integer id, Integer status, String msg, String instanceId) {
        BDingTalkDO bDingTalkDO = new BDingTalkDO();
        bDingTalkDO.setId(id);
        bDingTalkDO.setStatus(status);
        bDingTalkDO.setUpdatedAt(new Date());
        bDingTalkDO.setMsg(msg);
        bDingTalkDO.setInstanceId(instanceId);
        return bDingTalkDao.update(bDingTalkDO);
    }

    @Override
    public List<BDingTalkDTO> getListByTypeAndValid(Integer type) {
        return bDingTalkDao.selectListByTypeAndValid(type);
    }

    @Override
    public BDingTalkDTO getById(Integer id) {
        return bDingTalkDao.getById(id);
    }

    @Override
    public void updateDingTalkStatusBySourceIdsAndType(String sourceIds, Integer type, Integer status, String msg, String instanceId) {
        bDingTalkDao.updateDingTalkStatusBySourceIdsAndType(sourceIds,type,status,msg,instanceId);
    }

    @Override
    public BDingTalkDTO getByInstanceIdAndType(String instanceId, int type) {
        return bDingTalkDao.getByInstanceIdAndType(instanceId,type);
    }
}
